package
{
	import mx.collections.ArrayCollection;

	public class Global
	{
		public static const VERSION:String = "2013-04-17 @Yuga Present.";
		
		public static const WORK_TYPE:String = Global.WORK_DEBUG_17A;
		
		public static const SERVER_DEVICE_URL:String = "http://cp.110cws.com/index.php";
		
		public static const SERVER_LOGIN_URL:String = "http://www.110cws.com/e/enews/index.php";
		public static const SERVER_LOGOUT_URL:String = "http://www.110cws.com/e/enews/?enews=exit&ecmsfrom=9";
		public static const SERVER_CHANGE_PWD_URL:String = "http://www.110cws.com/e/member/EditInfo/EditSafeInfo.php";
		
		public static const TAOBAO_URL:String = "http://110cws.taobao.com";
		public static const TUANWANG_URL:String = "http://www.110cws.com";
		
		
		public static const WORK_DEFAULT : String = "default";
		public static const WORK_DEBUG_17A : String = "17A";
		public static const WORK_DEBUG_17B : String = "17B";
		
		/** 轨迹动画速度 */
		public static var playSpeed:Number = 0;
//		public static var isPause:Boolean = false;
		
		public static var ACC_OPEN_STR:String = 'ACC开';
		public static var ACC_CLOSE_STR:String = 'ACC关';
		
		public static var newsHtmlStr:String = '';
		public static var gonggaoHtmlStr:String = '';
		
		/**********************************测试数据开始*********************************************/
		/**		
		 * 查询报警信息间隔
		 **/
		public static const INTERVAL_QUERY_ALARM : int  = 3 * 1000 ;
		
		/**		
		 * 是否测试模式
		 **/
		public static const IS_DEBUG_MODE : Boolean = false;
		
		/**		
		 * 是否是企业用户
		 **/
		public static const TEST_IS_VIP_MODE : Boolean = false;
		
		/**
		 * 测试VIP客户
		 **/
		public static const TEST_VIP : Object = {status:1,  data:{username:"aaa", groupid:3} };
		
		/**
		 * 测试普通客户
		 **/
		public static const TEST_MEMEBER : Object = {status:1,  data:{username:"bbb", groupid:1} };
		
		
		/**
		 * 测试
		 * 登陆成功后第一个数据
		 **/
		public static const TEST_LOGIN_SUCCESS : Object = { status:1, data:{checked:"1",email:"szyhwl@163.com",groupid:"3",havemsg:"0",money:"0.00",password:"",registertime:"2012-04-23 14:45:09",rnd:"Z23zptbfZmKM",salt:"",userdate:"0",userfen:"0",userid:"28",username:"深圳永华网络",zgroupid:1}}

		/**
		 * 测试
		 * 会员信息列表	
		 **/
		public static const TEST_LOGIN_MEM_INFO : Object =  { status:1, data:[{node_id:"10",node_name:"深圳永华网络",parent_id:0,parent_node_str:"2",sort_id:"0"},{node_id:"11",node_name:"个人用户",parent_id:"10",parent_node_str:"2,10",sort_id:"0"},{node_id:"13",node_name:"瑞兴达",parent_id:"10",parent_node_str:null,sort_id:"0"}]};

		/**
		 * 获取设备列表
		 * onMemberDeviceCompleteHandler(data) 
		 *
		 **/ 
		public static const TEST_LOGIN_DEVICE_INFO : Object =  {status:1, data:[
			{activate_stamp:"1338454575",
				alarm_table:"gt06_alarm",
				alarm_type:"1",
				comment:"0000",
				contact_company:"0000",
				contact_phone:"0000",
				contact_user:"粤BU781W",
				db_id:"4",
				db_pre:"gt06_",
				device_alias_field:"client_id",
				device_id:"65",
				device_pin:"",
				device_type:"10",
				display_id:"1",
				expire_date:"2013-05-31 16:53:17",
				id:"65",
				is_general:"Y",
				key_str:"7b8vrqpf",
				member_id:"38",
				member_mobile:"NULL",
				member_name:"粤BU781W",
				name:"车",
				nickname:null,	
				node_id:"11",
				protocol_id:"5",
				protocol_name:"gt06",
				sim_number:"",
				sn:"0868120100466850",
				status:"0",
				type_id:"10",
				type_name:"gt06车载机",
				user_id:"12"
			},
			{activate_stamp:"1343640868",
				alarm_table:"gt06_alarm",
				alarm_type:"1",
				comment:"11111",
				contact_company:"1111",
				contact_phone:"1111",
				contact_user:"宝丰泰",
				db_id:"4",
				db_pre:"gt06_",
				device_alias_field:"client_id",
				device_id:"183",
				device_pin:"1111",
				device_type:"10",
				display_id:"1",
				expire_date:"2013-07-12 15:23:57",
				id:"183",
				is_general:"Y",
				key_str:"egudv39a",
				member_id:"139",
				member_mobile:"NULL",
				member_name:"宝丰泰",
				name:"车",
				nickname:null,	
				node_id:"11",
				protocol_id:"5",
				protocol_name:"gt06",
				sim_number:"11111",
				sn:"0868120100467569",
				status:"0",
				type_id:"10",
				type_name:"gt06车载机",
				user_id:"12"		
			}
		]}
		
		/**
		 * 测试
		 * 会员设备信息	
		 **/
		public static const TEST_LOGIN_MEM_DEVICE_INFO : Object =  {status:1,data:[{11:"105"}]};
		
		/**********************************测试数据结束*********************************************/
		
		public static var currentMapType:int = 1;

		public static var deviceType:int = 1;
		
		public static var deviceDisplayType:int = 0;
		
		public static var alertWindowList_optionState:String = "optionState";
		public static var alertWindowList_activeState:String = "activeState";
		public static var alertWindowList_alarmState:String = "alarmState";
		public static var alertWindowList_elecFenceState:String = "elecFenceState";
		public static var alertWindowList_renewalsState:String = "renewalsState";
		public static var alertWindowList_viewModelState:String = "viewModelState";
		public static var alertWindowList_closeState:String = "closeState";
		
		private static var _currentDeviceData:Object;
//		public static var currentDeviceData:Object;
		public static function get currentDeviceData():Object
		{
			return _currentDeviceData;
		}
		public static function set currentDeviceData(obj:Object):void
		{
			_currentDeviceData = obj;
		}
		
		private static var _currentDeviceInfo:Object;
//		public static var currentDeviceInfo:Object;
		public static function get currentDeviceInfo():Object
		{
			return _currentDeviceInfo;
		}
		public static function set currentDeviceInfo(obj:Object):void
		{
			_currentDeviceInfo = obj;
		}
		
		public static var openLoading:Function;
		public static var hideLoading:Function;
		
		public static var currentUserInfo:Object;
		
		public static var isVIP:Boolean;
		public static var filterDeviceArray:ArrayCollection = new ArrayCollection();
		
		/** 所有设备列表 */
		public static var deviceAllArray:ArrayCollection = new ArrayCollection();
		
		public static function getServerPathByAction(action:String):String
		{
			
			return SERVER_DEVICE_URL + "?action=interface-" + action;
		}
		
		public static function get systemTime():Number
		{
			var date:Date = new Date();
			return date.getTime();
		}
		
		public static function getTimeByTimeStr(str:String,hasSecond:Boolean=false):Number
		{
			var year:int = int(str.substr(0,4));
			var mon:int = int(str.substr(5,2)) - 1;
			var day:int = int(str.substr(8,2));
			
			var date:Date
			if(hasSecond)
			{
				var hour:int = int(str.substr(11,2));
				var min:int = int(str.substr(14,2));
				var sec:int = int(str.substr(17,2));
				date = new Date(year,mon,day,hour,min,sec);
			}else
			{
				date = new Date(year,mon,day);
			}
			
			var time:Number = date.getTime();
			trace("time:",time);
			return time;
		}
		
		public static function getTimeStrByTime(time:Number,hasSecond:Boolean=false):String
		{
			if(time.toString().length <= 10)
			{
				time = time * 1000;
			}
			var date:Date = new Date(time);
			
			var str:String = date.getFullYear() + "-" + getTimeFormatByNum(date.getMonth()+1) + "-" + getTimeFormatByNum(date.getDate());
			if(!hasSecond)
			{
				return str;
			}else
			{
				return str + " " + getTimeFormatByNum(date.getHours()) + ":" + getTimeFormatByNum(date.getMinutes()) +":"+ getTimeFormatByNum(date.getSeconds());
			}
			
		}
		
		public static function getTenTimeByTime(time:Number):String
		{
			var str:String = "" + time;
			str = str.substr(0,10);
			return str;
		}
		
		private static function getTimeFormatByNum(num:int):String
		{
			if(num < 10)
			{
				return "0" + num;
			}else
			{
				return num + "";
			}
		}
	}
}